package com.ruoyi.sale.mapper;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import com.ruoyi.sale.domain.Sale;
import org.apache.ibatis.annotations.Select;

/**
 * 商品销售Mapper接口
 * 
 * @author ruoyi
 * @date 2024-09-26
 */
public interface SaleMapper 
{
    /**
     * 查询商品销售
     * 
     * @param id 商品销售主键
     * @return 商品销售
     */
    public Sale selectSaleById(Integer id);

    /**
     * 查询商品销售列表
     * 
     * @param sale 商品销售
     * @return 商品销售集合
     */
    public List<Sale> selectSaleList(Sale sale);

    /**
     * 新增商品销售
     * 
     * @param sale 商品销售
     * @return 结果
     */
    public int insertSale(Sale sale);

    /**
     * 修改商品销售
     * 
     * @param sale 商品销售
     * @return 结果
     */
    public int updateSale(Sale sale);

    /**
     * 删除商品销售
     * 
     * @param id 商品销售主键
     * @return 结果
     */
    public int deleteSaleById(Integer id);

    /**
     * 批量删除商品销售
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteSaleByIds(Integer[] ids);
    @Select("select COUNT(*) AS total_orders \n" +
            "FROM sale \n" +
            "WHERE DATE(sale_time) = CURDATE();")
  Integer statisOrder();
    @Select("SELECT SUM(sale_total_price) AS total_sales_amount \n" +
            "FROM sale\n" +
            "WHERE DATE(sale_time) = CURDATE();")
    BigDecimal statisTotalPrice();
    @Select("SELECT DISTINCT Day(sale_time) FROM sale ORDER BY DATE(sale_time) ASC ")
    List<Integer> getAllSalesOrderedByTime();
    @Select("select sale_total_price from sale GROUP BY DATE(sale_time) order by sale_time ASC;")
    List<Integer> getAllTotalByTime();
    @Select("SELECT COUNT(*)" +
            "FROM sale " +
            "GROUP BY DATE(sale_time) " +
            "ORDER BY sale_time ASC")
    List<Integer> getAllSalesOrder();
}
